<template>
  <view class="page-status-bar"></view>
  <view class="page-wrapper page-space">
    <view v-for="x in data" :key="x.id" class="list-item">
      <view>内容：<text>{{ x.content }}</text></view>
      <view>时间：<text>{{ x.datetime }}</text></view>
      <view>类型：<text>{{ NoticeTypeEnum[x.type] }}</text></view>
      <view>接收人：<text>{{ NoticeRecipientTypeEnum[x.recipientType] }}</text></view>
    </view>
    <lg-list-more :has-more="hasMore" :loading="loading" @load-more="loadMore"/>
  </view>
</template>

<script setup lang="ts">
import {onRefresh} from '@/soar/hooks/refresh';
import {useList} from '@/soar/hooks/page';
import LgListMore from "@/soar/components/lg-list-more/index.vue";
import api from "@/api/message";
import {mustLogin} from "@/store/account";
import {useDict} from "@/soar/hooks/dict";

mustLogin();

const { NoticeTypeEnum, NoticeRecipientTypeEnum } = useDict(['NoticeTypeEnum', 'NoticeRecipientTypeEnum'])

onRefresh(() => {
  onQuery()
  console.log('刷新');
})

const { data, loadMore, onQuery, hasMore, loading } = useList<any>({
  api
})

</script>

<style lang="scss">
.page-wrapper {
  background: #f7f7f7;
  .list-item {
    background: #fff;
    padding: 24rpx;
    border-radius: 4px;
    &+.list-item {
      margin-top: 24rpx;
    }
  }
}
</style>
